<?php $this->load->view('layout/header');?>
<div class="supplier-content-page">
    <div class="product-test-h5">
        <ul class="breadcrumb">
            <li><a href="javascript:;">我的账户</a></li>
            <li><a href="<?php echo site_url('accountinfo/accountRecord');?>">账户信息</a></li>
            <li class="active"><a href="<?php echo site_url('accountinfo/rebate')?>">结算</a></li>
        </ul>
        <?php echo execute_alert_message();?>
        <div class="add-product">
            <form class="rebate-validate-form form-horizontal" action="<?php echo site_url('accountinfo/rebateDo') ?>" method="post" enctype="multipart/form-data">
                <div class="fonter">申请结算</div>
                <div class="form-group">
                    <label class="col-sm-1 control-label"><em>* </em>打款金额</label>
                    <div class="col-xs-3">
                        <input type="hidden" name="oval" value="<?php echo abs($userAccount->amount_month)?>"/>
                        <input type="text" name="o_income" value="<?php echo abs($userAccount->amount_month)?>" class="form-control required number priceValid" placeholder="返利金额">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-1 control-label"><em>* </em>抵扣余额</label>
                    <div class="col-xs-3">
                        <input type="text" name="deduction" value="<?php echo (abs($userAccount->amount_month)<abs($userAccount->amount_carry)) ? abs($userAccount->amount_month) : abs($userAccount->amount_carry);?>" class="form-control required number priceValid" placeholder="可提现金额">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-1 control-label"><em>* </em>打款单位</label>
                    <div class="col-xs-3">
                        <input type="text" name="name" class="form-control required"/>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-1 control-label"><em>* </em>联系方式</label>
                    <div class="col-xs-3">
                        <input type="text" name="contact" class="form-control mobile required"/>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-1 control-label">实际打款</label>
                    <div class="col-xs-3">
                        <span id="r_income" class="text-primary">0</span>
                    </div>
                </div>
                <div class="supplierlist-submit">
                    <button type="submit" class="btn btn-default">确认结算</button>
                    <a href="<?php echo site_url('accountinfo/accountRecord');?>">返回上一级</a>
                </div>
            </form>
        </div>
    </div>
</div>
<script type="text/javascript"> 
$(document).ready(function(){
    jQuery.validator.addMethod('priceValid', function(value, element) {
        var priceValid  = true;
        var o_income  = parseFloat($('input[name=o_income]').val());
        var deduction = parseFloat($('input[name=deduction]').val());
        var in_income = o_income-deduction;
        if ((o_income < deduction) || o_income <= 0 || deduction <= 0) {
            priceValid = false;
        } else {
            $('#r_income').text(in_income.toFixed(2));
        }
        return this.optional(element) || priceValid;
    }, '打款金额必须大于抵扣金额，并且金额需大于零');
    
    $('.rebate-validate-form').validate();
});
</script>
<?php $this->load->view('layout/footer');?>